<template>
  <div class="set-app">
    <div style="margin: 5px 0;height:50px;width:100%;">
      <sticky :sticky-top="80" class-name="submit-button">
        <el-button type="primary">提交</el-button>
      </sticky>
    </div>
    <div class="set-app-header top">APP 设置</div>
    <el-form ref="appForm" :model="form" label-width="207px" class="appForm">
      <el-form-item label="是否开启客户端">
        <el-radio-group v-model="form.Operate">
          <el-radio :label="true">开启</el-radio>
          <el-radio :label="false">关闭</el-radio>
        </el-radio-group>
      </el-form-item>
      <el-form-item label="网校简介">
        <tinymce v-model="form.tinymce" :height="150" :show="true" style="width:500px"/>
      </el-form-item>
      <el-form-item label="网校简介">
        <el-upload
          :file-list="fileList"
          :auto-upload="false"
          list-type="picture"
          style="width:800px"
          action="https://jsonplaceholder.typicode.com/posts/"
        >
          <el-button slot="trigger" size="small" type="primary">上传</el-button>
          <div slot="tip" class="el-upload__tip">
            请上传jpg, gif, png格式的图片。logo 图片的高度建议不超过50px。图片大小建议不超过2MB。
            <el-button type="text" @click="makeImg">如何制作合适的图片</el-button>
          </div>
        </el-upload>
      </el-form-item>
      <div class="set-app-header top">定制APP设置项</div>
      <div
        class="help-block"
      >请上传jpg, gif, png格式的图片。最多设置5张启动图，建议图片尺寸为 640×960px，建议图片大小不超过2MB。用户首次登录网校时会显示启动图。</div>
      <template v-for="(item, index) in startImg">
        <el-form-item :key="index" :label="'启动图'+(index+1)">
          <el-upload
            :ref="'startImg'+(index+1)"
            :file-list="item.fileList"
            :auto-upload="false"
            list-type="picture"
            style="width:800px"
            action="https://jsonplaceholder.typicode.com/posts/"
          >
            <el-button slot="trigger" size="small" type="primary">上传</el-button>
            <div slot="tip" class="el-upload__tip">请上传jpg, gif, png格式的图片。</div>
          </el-upload>
        </el-form-item>
      </template>
    </el-form>
  </div>
</template>

<script>
import Tinymce from '@/components/Tinymce'
import Sticky from '@/components/Sticky'
export default {
  components: {
    Tinymce,
    Sticky
  },
  data() {
    return {
      form: {
        tinymce: '',
        Operate: true
      },
      startImg: [
        {
          id: 1,
          fileList: []
        },
        {
          id: 2,
          fileList: []
        },
        {
          id: 3,
          fileList: []
        },
        {
          id: 4,
          fileList: []
        },
        {
          id: 5,
          fileList: []
        }
      ]
    }
  },
  methods: {
    makeImg() {
      window.open('http://www.qiqiuyu.com/faq/539/detail')
    }
  }
}
</script>

<style lang="scss">
.set-app {
  .submit-button {
    width: 100%;
    line-height: 50px;
    height: 50px !important;
    text-align: right;
    padding-right: 30px;
    background-color: #ebf4ff;
  }
  .top {
    margin-top: 20px;
  }
  .help-block {
    display: block;
    margin-top: 5px;
    margin-bottom: 15px;
    color: #737373;
    margin-left: 180px;
  }
  &-header {
    font-size: 16px;
    padding: 10px 20px;
    border-bottom: 1px solid #ddd;
    background-color: #fafafa;
    margin-bottom: 10px;
  }
}
</style>
